

// store/reducer.js
import {
  ADD_BANNER,
  ADD_RECOMMEND,
  FETCH_MULTI_DATA_FAIL
} from './constants.js'


// fetchDataReducer
const initStateFetchData = {
  banners: [],
  recommend: [],
  errMsg: ''
}
export default function fetchDataReducer(state = initStateFetchData, action){
  switch(action.type){
    case ADD_BANNER:
      return {...state, banners: [...state.banners, ...action.banners]}
    case ADD_RECOMMEND:
      return {...state, recommend: [...state.recommend, ...action.recommend]}
    case FETCH_MULTI_DATA_FAIL:
      return {...state, errMsg: action.errMsg}
    default:
      return state
  }
}
